package com.serookie.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.serookie.entity.Address;
import com.serookie.entity.GoodsCategory;
import com.serookie.mapper.AddressMapper;
import com.serookie.mapper.GoodsCategoryMapper;
import com.serookie.service.AddressService;
import com.serookie.service.GoodsCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author kevintam
 * @version 1.0
 * @date 2021/5/8 15:31
 */
@Service
public class AddressServiceImpl extends ServiceImpl<AddressMapper, Address> implements AddressService{

    @Autowired
    private AddressMapper addressMapper;

    @Override
    public Boolean addAddress(Address address) {
        return addressMapper.insert(address)>0;
    }

    @Override
    public List<Address> all() {
        return addressMapper.selectList(null);
    }


    @Override
    public Boolean updateAddress(Address address) {
        return addressMapper.updateById(address)>0;
    }

    @Override
    public Address getById(String openid) {
        QueryWrapper<Address> wrapper = new QueryWrapper<>();
        wrapper.eq("openid",openid);
        return addressMapper.selectOne(wrapper);
    }
}
